﻿using System;
using System.Collections.ObjectModel;
using System.Windows;
using PairingMatrix.Common;
using PairingMatrix.Common.Command;
using PairingMatrix.Common.Enum;
using PairingMatrix.Model;

namespace PairingMatrix.ViewModel
{
    public class MingleCardViewModel : ViewModelBase, IProjectCardViewModel
    {
        public ObservableCollection<IProjectCardViewModel> SecondaryProjectCards { get; set; }

        private readonly ProjectCardModel _model;

        public MingleCardViewModel(ProjectCardModel model)
        {
            this._model = model;
            SecondaryProjectCards = new ObservableCollection<IProjectCardViewModel>();
            _model.PropertyChanged += _model_PropertyChanged;
            ShowCard = true;
        }

        void _model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if(IsValidProperty(e.PropertyName))
                OnPropertyChanged(e.PropertyName);
        }

        public int CardNumber
        {
            get { return _model.CardNumber; }
            set
            {
                OnPropertyChanged("CardNumber");
            }
        }

        public int Priority
        {
            get { return _model.Priority; }
            set
            {
                OnPropertyChanged("Priority");
            }
        }


        public string Title
        {
            get { return _model.Title; }
            set
            {
                OnPropertyChanged("Title");
            }
        }

        public string Note
        {
            get { return ""; }
            set {  }
        }

        private Point _centerPoint;
        public Point CenterPoint 
        {
            get { return _centerPoint; }
            set
            {
                OnPropertyChanged("CenterPoint");
            }
        }


        private Point _position;
        public Point Position
        {
            get { return _position; }
            set
            {
                if (_position == value)
                    return;
                _position = value;
                OnPropertyChanged("Position");
            }
        }


        private bool _showHighlighted;

        public Point PositionOnWallOnly
        {
            set {  }
        }

        public bool ShowHighlighted
        {
            get { return _showHighlighted; }
            set
            {
                if (_showHighlighted == value)
                    return;
                _showHighlighted = value;
                OnPropertyChanged("ShowHighlighted");
            }
        }

        private bool _showCard;

        public string StatusInMingle
        {
            get { return _model.StatusInMingle; }
            set
            {
                if (_model.StatusInMingle == value)
                    return;
                _model.StatusInMingle = value;
                OnPropertyChanged("StatusInMingle");
            }
        }

        public bool ShowCard
        {
            get { return _showCard; }
            set
            {
                if (_showCard == value)
                    return;
                _showCard = value;
                OnPropertyChanged("ShowCard");
            }
        }

        public bool IsCardVisibleInCurrentWall
        {
            get { return _model.IsCardVisibleInCurrentWall; }
        }

        public bool CanAcceptMoreTeamMember()
        {
            return false;
        }

        public bool IsSyncing
        {
            get { return false; }
        }

        public int NumberOfSignUps
        {
            get { return 0; }
        }

        public double DevEstimate
        {
            get { return 0; }
        }

        public Urgency Urgency
        {
            get { return Urgency.NotUrgent; }
        }

        public ProjectCardModel PrimaryCard
        {
            get { return null; }
        }

        public RelayCommand RemoveFromWallCommand
        {
            get { return null; }
        }

        public RelayCommand ToggleNotesVisibilityCommand
        {
            get { return null; }
        }

        public int ZIndex
        {
            get { return 0; }
            set { }
        }


        public ProjectCardModel Model
        {
            get { return _model; }
        }

        public StoryStatus DevStage
        {
            get { return _model.DevStage; }
            set 
            { 
                OnPropertyChanged("DevStage");
            }
        }

        private bool _isInEditMode;
        public bool IsInEditMode
        {
            get { return _isInEditMode; }
            set
            {
                OnPropertyChanged("IsInEditMode");
            }
        }

        public bool ShowDaysSpentForProjectCards
        {
            get { return false; }
        }


    }
}